package com.shou.infrastructure.persistent.repository;

import com.shou.domain.common.IBaseRepository;
import com.shou.infrastructure.persistent.dao.IBaseDao;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * ClassName:BaseRuleRepository
 * Project:yvt-rule
 * Package: com.sunlight.infrastructure.adapter.repository
 * Description
 *
 * @Author Nemo
 * @Create 2024/12/24 17:32
 * @Version 1.0
 */
@Repository("baseRepository")
public class BaseRepository implements IBaseRepository {
    @Resource
    IBaseDao baseDao;

    @Override
    public void deleteByIds(List<Integer> ids, String tableName) {
        baseDao.deleteByIds(ids, tableName);
    }

    @Override
    public boolean checkIfExistById(Integer id, String tableName) {
        return baseDao.checkIfExistById(id, tableName);
    }

    @Override
    public boolean checkIfExistByCode(String code, String tableName, Integer[] excludeIds) {
        return baseDao.checkIfExistByCode(code, tableName, excludeIds);
    }

    @Override
    public boolean checkIfSpaceExistByCode(String code, String tableName, Integer[] excludeIds, String lotCode) {
        return baseDao.checkIfSpaceExistByCode(code, tableName, excludeIds, lotCode);
    }

    @Override
    public List<String> getColumnsByEnTableName(String enTableName) {
        return baseDao.selectColumnsByEnTableName(enTableName);
    }

    @Override
    public boolean checkIfExistByName(String name, String enTableName, Integer[] excludeIds) {
        return baseDao.checkIfExistByName(name, enTableName, excludeIds);
    }

    @Override
    public boolean checkIfExistByReservedUserId(Integer userId, String enTableName, Integer[] excludeIds) {
        return baseDao.checkIfExistByReservedUserId(userId, enTableName, excludeIds) > 1;
    }

    @Override
    public boolean checkIfAvailableBySpaceCode(String spaceCode, String enTableName, Integer[] excludeIds) {
        return baseDao.checkIfAvailableBySpaceCode(spaceCode, enTableName, excludeIds);
    }

    @Override
    public boolean checkIfRecordsExist(String tableName) {
        return baseDao.checkIfRecordsExist(tableName);
    }

    @Override
    public void deleteAllByTableName(String tableName) {
        baseDao.deleteAllByTableName(tableName);
    }
}
